﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hong.Pan
{
    public class PanFileInfo
    {
        /// <summary>
        /// 文件图标
        /// </summary>
        public string icon { get; set; } = string.Empty;

        /// <summary>
        /// 是否是目录
        /// </summary>
        public bool isdir { get; set; } = false;

        /// <summary>
        /// 盘的绝对路径
        /// </summary>
        public string path { get; set; } = string.Empty;

        /// <summary>
        /// 文件大小
        /// </summary>
        public long size { get; set; } = 0;

        /// <summary>
        /// 是否已经下载
        /// </summary>
        public bool loaded { get; set; } = false;

        /// <summary>
        /// 背景颜色
        /// </summary>
        public Object? background { get; set; }

        /// <summary>
        /// 已下载大小
        /// </summary>
        public int loadsize { get; set; } = 0;

        /// <summary>
        /// 文件ID
        /// </summary>
        public string fid { get; set; } = string.Empty;

        /// <summary>
        /// 文件大小的显示格式
        /// </summary>
        public string sizeText
        {
            get {
                if (size > 1024 * 1024 * 1024)
                {
                    return string.Format("{0:F2}G", size / (1024 * 1024 * 1024.0));
                }
                else if (size > 1024 * 1024)
                {
                    return string.Format("{0:F2}M", size / (1024 * 1024.0));
                }
                else if (size > 1024)
                {
                    return string.Format("{0:F2}K", size / 1024.0);
                }
                else 
                {
                    return size.ToString();
                }
            }
        }

        /// <summary>
        /// 文件名
        /// </summary>
        public string filename { get; set; } = string.Empty;
    }
}
